<template>
	<view style="padding-top: 20upx;">
		<view class="webkit list">
			<view class="title">银行卡号</view>
			<input type="text" @input="bankcardInput" class="flex" v-model="bankcard" placeholder="请输入银行卡号" placeholder-style="color:#aaa;font-size:30upx" />
		</view>
		<view class="webkit list">
			<view class="title">银行名称</view>
			<input type="text"  disabled="disabled" v-model="bankcardname" style="color:#aaa;font-size:30upx;padding-left: 20upx;" />
		</view>
		<view class="webkit list">
			<view class="title">身份证号</view>
			<input type="number" @input="idcardInput" class="flex" v-model="idcard" placeholder="请输入身份证号" placeholder-style="color:#aaa;font-size:30upx" />
		</view>
		<view class="webkit list">
			<view class="title">预留手机号</view>
			<input type="number" @input="telephoneInput" class="flex" v-model="telephone" placeholder="请输入预留手机号" placeholder-style="color:#aaa;font-size:30upx" />
		</view>
		<view class="webkit list">
			<view class="title">开户人</view>
			<input type="text" @input="nameInput" class="flex" v-model="name" placeholder="请输入开户人" placeholder-style="color:#aaa;font-size:30upx" />
		</view>
		
		<view style="padding: 0 24upx;">
			<button type="primary" style="background-image: linear-gradient(to bottom, rgb(243, 109, 31), rgb(252, 9, 9));margin-top: 20upx;" @click="submit" :loading="loading">确认提交</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				bankcardname:'',
				bankcard:'',
				idcard:'',
				telephone:'',
				name:'',
				loading: false,
				openid:''
			};
		},
		onLoad:function(){
			uni.getStorage({
				key: 'openid',
				success: (res) => {
					this.openid = res.data
				},
				fail: () => {
					uni.navigateTo({
						url: '../../login/login'
					});
				}
			});
		},
		methods:{
			nameInput(e) {
				this.name = e.target.value
			},
			idcardInput(e) {
				this.idcard = e.target.value
			},
			bankcardInput(e) {
				this.bankcard = e.target.value
				if (this.bankcard.length >= 12) {
					uni.request({
						url: 'https://ccdcapi.alipay.com/validateAndCacheCardInfo.json?cardNo='+this.bankcard+'&cardBinCheck=true',
						method: 'GET',
						header: {
							'Content-Type': 'application/x-www-form-urlencoded'
						},
						success: res => {
							console.log(res.data)
							var b = res.data.bank
							const bank = {
								"CDB":"国家开发银行","ICBC":"中国工商银行","ABC":"中国农业银行","BOC":"中国银行","CCB":"中国建设银行","PSBC":"中国邮政储蓄银行","COMM":"交通银行","CMB":"招商银行","SPDB":"上海浦东发展银行","CIB":"兴业银行","HXBANK":"华夏银行","GDB":"广东发展银行","CMBC":"中国民生银行","CITIC":"中信银行","CEB":"中国光大银行","EGBANK":"恒丰银行","CZBANK":"浙商银行","BOHAIB":"渤海银行","SPABANK":"平安银行","SHRCB":"上海农村商业银行","YXCCB":"玉溪市商业银行","YDRCB":"尧都农商行","BJBANK":"北京银行","SHBANK":"上海银行","JSBANK":"江苏银行","HZCB":"杭州银行","NJCB":"南京银行","NBBANK":"宁波银行","HSBANK":"徽商银行","CSCB":"长沙银行","CDCB":"成都银行","CQBANK":"重庆银行","DLB":"大连银行","NCB":"南昌银行","FJHXBC":"福建海峡银行","HKB":"汉口银行","WZCB":"温州银行","QDCCB":"青岛银行","TZCB":"台州银行","JXBANK":"嘉兴银行","CSRCB":"常熟农村商业银行","NHB":"南海农村信用联社","CZRCB":"常州农村信用联社","H3CB":"内蒙古银行","SXCB":"绍兴银行","SDEB":"顺德农商银行","WJRCB":"吴江农商银行","ZBCB":"齐商银行","GYCB":"贵阳市商业银行","ZYCBANK":"遵义市商业银行","HZCCB":"湖州市商业银行","DAQINGB":"龙江银行","JINCHB":"晋城银行JCBANK","ZJTLCB":"浙江泰隆商业银行","GDRCC":"广东省农村信用社联合社","DRCBCL":"东莞农村商业银行","MTBANK":"浙江民泰商业银行","GCB":"广州银行","LYCB":"辽阳市商业银行","JSRCU":"江苏省农村信用联合社","LANGFB":"廊坊银行","CZCB":"浙江稠州商业银行","DYCB":"德阳商业银行","JZBANK":"晋中市商业银行","BOSZ":"苏州银行","GLBANK":"桂林银行","URMQCCB":"乌鲁木齐市商业银行","CDRCB":"成都农商银行","ZRCBANK":"张家港农村商业银行","BOD":"东莞银行","LSBANK":"莱商银行","BJRCB":"北京农村商业银行","TRCB":"天津农商银行","SRBANK":"上饶银行","FDB":"富滇银行","CRCBANK":"重庆农村商业银行","ASCB":"鞍山银行","NXBANK":"宁夏银行","BHB":"河北银行","HRXJB":"华融湘江银行","ZGCCB":"自贡市商业银行","YNRCC":"云南省农村信用社","JLBANK":"吉林银行","DYCCB":"东营市商业银行","KLB":"昆仑银行","ORBANK":"鄂尔多斯银行","XTB":"邢台银行","JSB":"晋商银行","TCCB":"天津银行","BOYK":"营口银行","JLRCU":"吉林农信","SDRCU":"山东农信","XABANK":"西安银行","HBRCU":"河北省农村信用社","NXRCU":"宁夏黄河农村商业银行","GZRCU":"贵州省农村信用社","FXCB":"阜新银行","HBHSBANK":"湖北银行黄石分行","ZJNX":"浙江省农村信用社联合社","XXBANK":"新乡银行","HBYCBANK":"湖北银行宜昌分行","LSCCB":"乐山市商业银行","TCRCB":"江苏太仓农村商业银行","BZMD":"驻马店银行","GZB":"赣州银行","WRCB":"无锡农村商业银行","BGB":"广西北部湾银行","GRCB":"广州农商银行","JRCB":"江苏江阴农村商业银行","BOP":"平顶山银行","TACCB":"泰安市商业银行","CGNB":"南充市商业银行","CCQTGB":"重庆三峡银行","XLBANK":"中山小榄村镇银行","HDBANK":"邯郸银行","KORLABANK":"库尔勒市商业银行","BOJZ":"锦州银行","QLBANK":"齐鲁银行","BOQH":"青海银行","YQCCB":"阳泉银行","SJBANK":"盛京银行","FSCB":"抚顺银行","ZZBANK":"郑州银行","SRCB":"深圳农村商业银行"
							}
							var obj
							for(obj in bank) {
								if (obj == b) {
									// console.log(bank[obj])
									this.bankcardname = bank[obj]
								}
							}
						},
						fail: () => {},
						complete: () => {}
					});
				}
			},
			telephoneInput(e) {
				this.telephone = e.target.value
			},
			submit(){
				if (this.bankcard == "") {
					uni.showToast({
						title: '请输入银行卡号',
						icon: "none"
					});
				} else if (this.idcard == "") {
					uni.showToast({
						title: '请输入身份证号',
						icon: "none"
					});
				} else if (this.telephone == "") {
					uni.showToast({
						title: '请输入预留手机号',
						icon: "none"
					});
				} else if (this.name == "") {
					uni.showToast({
						title: '请输入开户人',
						icon: "none"
					});
				} else {
					uni.request({
						url: 'https://bhh.ax1319.com/app/index.php?i=4&c=entry&m=ewei_shopv2&do=mobile&r=member.bank_bind&app=1',
						method: 'POST',
						data: {
							bank_name: this.bankcardname,
							acc_no: this.bankcard,
							mobile: this.telephoneInput,
							idcard: this.idcard,
							name:this.name,
							openid: this.openid
						},
						header: {
							'Content-Type': 'application/x-www-form-urlencoded'
						},
						success: res => {
							console.log(res)
							uni.showToast({
								title: res.data.message,
								icon: "none"
							});
						},
						fail: () => {},
						complete: () => {}
					});
				}
			}
			
		}
	}
</script>

<style>
	.list{padding:16upx 24upx;background:#fff;position:relative;}.list:last-child:after{display:none;}.list:after{content:" ";position:absolute;left:20upx;right:20upx;bottom:-2upx;height:2upx;border-top:2upx solid #ebebeb;color:#D9D9D9;-webkit-transform-origin:0 0;-ms-transform-origin:0 0;transform-origin:0 0;-webkit-transform:scaleY(0.5);-ms-transform:scaleY(0.5);transform:scaleY(0.5);}.list .title{width:150upx;line-height:50upx;color:#666;}.list .flex{line-height:50upx;color:#666;padding-left:24upx;}.inputright{width:200upx;height:52upx;}button.inputright{line-height:48upx;font-size:24upx;background:transparent;border:2upx solid #333;}</style>

